﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for CategoryDAL
/// </summary>
public class CategoryDAL
{
    DataAccess db = new DataAccess();
    public CategoryDAL()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    //display all category 
    public DataTable getAllCategory()
    {
        return db.executeSelect("GetAllCategory");
    }
    //display category by id
    public DataTable GetCategoryById(string _categoryid)
    {
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = new SqlParameter("@CategoryId", SqlDbType.VarChar, 50);
        paramList[0].Value = _categoryid;
        return db.executeSelect("GetCategoryById", paramList);
    }

    //add Category
    public int InsertCategory(Category category)
    {
        SqlParameter[] paramList = new SqlParameter[2];
        paramList[0] = new SqlParameter("@CategoryId", SqlDbType.VarChar, 30);
        paramList[0].Value = category.CategoryId;
        paramList[1] = new SqlParameter("@CategoryName", SqlDbType.VarChar, 50);
        paramList[1].Value = category.CategoryName;

        return db.executeUpdate("InsertCategory", paramList);
    }
    
}
